package com.engine4cloud.tdf.supervision.controller.web;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.supervision.dto.SpAuditDTO;
import com.engine4cloud.tdf.supervision.service.SpHelpAuditService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 审批-帮扶-审核-web
 *
 * @author wenjie
 * @date 2024-04-10 11:13:01
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/help/audit")
@Tag(description = "helpAuditWeb", name = "审批-帮扶-审核-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SpHelpAuditWebController {

    @Resource
    private SpHelpAuditService helpAuditService;

    /**
     * 司法所审核通过
     */
    @Operation(summary = "司法所审核通过", description = "司法所审核通过")
    @SysLog("司法所审核通过")
    @PutMapping("/audit")
    @PreAuthorize("@pms.hasPermission('help_audit')")
    public R<Boolean> audit(@Valid @RequestBody SpAuditDTO dto) {
        return R.ok(helpAuditService.audit(dto));
    }

    /**
     * 司法所拒绝（存在app端矫正对象发起外出申请的情况，所以有司法所拒绝动作）
     */
    @Operation(summary = "司法所拒绝", description = "司法所拒绝")
    @SysLog("司法所拒绝")
    @PutMapping("/refuse")
    @PreAuthorize("@pms.hasPermission('help_refuse')")
    public R<Boolean> refuse(@Valid @RequestBody SpAuditDTO dto) {
        return R.ok(helpAuditService.refuse(dto));
    }
}